<template>
  <div>
    <Collapse ref="collapseRef" :list="data">
      <template v-slot:title="{ item }">
        <div @click="handleClick(item)" class="flex list-item">
          <div>{{ item.title }}</div>
          <div class="arrow" :class="{ expend: item.show }">></div>
        </div>
      </template>
      <template #content="{ item }">
        <div class="list-content">
          <div class="list-content-item" v-for="i in item.list" :key="i.name">
            <div>{{ i.name }}</div>
            <div>{{ i.total }}</div>
          </div>
        </div>
      </template>
    </Collapse>
  </div>
</template>

<script lang="ts" setup>
import Collapse from "@/components/Collapse/index.vue";

const data = ref([
  {
    title: "肯德基",
    list: [
      {
        name: "吮指原味鸡",
        total: 100,
      },
      {
        name: "汉堡",
        total: 30,
      },
    ],
  },
  {
    title: "麦当劳",
    list: [
      {
        name: "麦辣鸡翅",
        total: 20,
      },
      {
        name: "麦辣鸡腿堡",
        total: 50,
      },
    ],
  },
  {
    title: "必胜客",
    list: [
      {
        name: "披萨",
        total: 200,
      },
      {
        name: "小食拼盘",
        total: 40,
      },
    ],
  },
]);

const collapseRef = ref(null);

const handleClick = (item: any) => {};
</script>

<style scoped lang="scss">
.arrow {
  color: var(--secondary);
}
.expend {
  transform: rotate(90deg);
  transition: all 0.1s;
}
.list-item {
  cursor: pointer;
}

.list-content {
  padding: 0 10px;
  margin: 10px;
  width: 500px;
  border: 1px solid var(--secondary);
}

.list-content-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--secondary);
  &:last-child {
    border-bottom: none;
  }
}
</style>
